<script setup lang="ts">
import dayjs from 'dayjs'
import {defineProps, onMounted, watch} from "vue";
const props = defineProps({
  date: {
    type: Number,
    default: null
  },
  type: {
    type: String,
    default: 'mm'
  },
});
const showDate = ref('/')
const init = () =>{
  if(!props.date){
    return;
  }
  if(props.type === 'ss'){
    showDate.value = dayjs(props.date*1000).format('YYYY-MM-DD HH:mm:ss')
  }
  if(props.type === 'mm'){
    showDate.value = dayjs(props.date*1000).format('YYYY-MM-DD HH:mm')
  }
  if(props.type === 'DD'){
    showDate.value = dayjs(props.date*1000).format('YYYY-MM-DD')
  }
}
watch(
    () => props.date,
    (newRoute) => {
      init()
      //mainMenuTitle = newPath
    },
    { deep: true, immediate: true }
);


onMounted(() =>{
  init()
})
</script>

<template>
<span>{{showDate}}</span>
</template>

<style scoped>

</style>